package interfaces.menu.options;

import interfaces.menu.AbsMenu;
import interfaces.options.OptionsContainer;
import fileHandling.ProfileHandler;
import fileHandling.language.interfaces.OptionsWindowText;
import fileHandling.language.options.Common;

import logic.nodes.nodeSettings.Settings;
import main.InitGame;

import settings.CommonSettings;

public class CommonOptionsContent extends OptionContent {
	
	private OptionsContainer configOptions, hudOptions;
	
	public CommonOptionsContent(OptionsMenu optionsMenu, AbsMenu menu) {
		super(optionsMenu, menu, "common.xml", CommonSettings.get());
		
		configOptions = createOptionsContainer(OptionsWindowText.Configuration, Common.Language);
		hudOptions = createOptionsContainer(OptionsWindowText.HUD, 
				Common.FOV, Common.Draw_FPS, Common.Crosshair_Color_R, Common.Crosshair_Color_G, 
				Common.Crosshair_Color_B, Common.Crosshair_Color_A, Common.Crosshair_Type, Common.Crosshair_Size);
	}
	
	@Override
	protected void apply() {
		CommonSettings settings = CommonSettings.get();
		settings.copySettings(new Settings(configOptions), false);
		settings.copySettings(new Settings(hudOptions), false);
		ProfileHandler.changeSettings(CommonSettings.get());
		InitGame.get().changeCommonSettings();
	}
}